var getUserInfo = function(that,data){
	return new Promise((resolve, reject) => {
		that.$util.sendRequest(that,"app.xcx.getUserInfo","POST",1,data).then(res=>{resolve(res)}).catch(err=>{reject(err)});
	});
};
var getOpenId = function(that){
	return new Promise((resolve, reject) => {
		uni.showLoading({title: '正在获取OPENID'});
		wx.login({
			success (res1) {
				if (res1.code) {
					that.$util.sendRequest(that,"app.xcx.getOpenId","POST",1,{code:res1.code}).then(res=>{
						that.setStore("openId", res["openId"]);
						that.setStore("unionId", res["unionId"]);
						resolve(res);
					}).catch(err=>{
						reject(err)
					});
				} else {
					uni.hideLoading();
					reject("获取授权失败");
				}
			},
			fail: function(errorMsg) {
				uni.hideLoading();
				reject("获取授权失败:"+errorMsg);
			}
		});
		
	});
};
module.exports = {
	getUserInfo: getUserInfo,
	getOpenId: getOpenId
}
